package inputDemo;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class Demo5 {
    public static void main(String[] args) throws IOException {
        // 1.打开文件
        InputStream inputStream = new FileInputStream("d:/test.txt");
        // 2.读取文件
        byte[] buf = new byte[1024];
        int len = inputStream.read(buf);
        String s = new String(buf, 0, len, "UTF8");
        System.out.println(s);
        // 3.关闭文件
        inputStream.close();

    }
}
